<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.prime.com.tr/ui">

    <ui:composition template="/WEB-INF/faces/template.xhtml">
        <ui:define name="title">
            <h:outputText value="All Drivers"></h:outputText>
        </ui:define>
        <ui:define name="content">
            <p:panel header="All Users" style="border: none;">
                <h:form >
                    <h:panelGroup id="messagePanel" layout="block">
                        <p:growl sticky="true"/>
                    </h:panelGroup>

                    <p:dataTable  value="#{driverBean.drivers}" var="item" height="200px" >
                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="Driver Name"/>
                            </f:facet>
                            <h:outputText value="#{item.driverName}"/>
                        </p:column>

                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="Contact Number"/>
                            </f:facet>
                            <h:outputText value="#{item.contactNumber}"/>
                        </p:column>
                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="Licence Number"/>
                            </f:facet>
                            <h:outputText value="#{item.licenceNumber}"/>
                        </p:column>
                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="Enrolled Date"/>
                            </f:facet>
                            <h:outputText value="#{item.enrolledDate}">
                                <f:convertDateTime pattern="dd/MM/yyyy"/>
                            </h:outputText>
                        </p:column>
                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="Address"/>
                            </f:facet>
                            <h:outputText value="#{item.address}"/>
                        </p:column>
                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="&nbsp;"/>
                            </f:facet>

                            <p:commandButton  action="#{driverBean.prepareEdit(item.id)}"  value="Edit"/>
                            <p:commandButton  action="#{driverBean.destroy(item.id)}" value="Delete"/>
                        </p:column>
                    </p:dataTable>
                    <br />
                    <p:commandButton  action="#{driverBean.prepareCreate}" value="Add New Driver"/>

                </h:form>
            </p:panel>
        </ui:define>
    </ui:composition>   
</html>